import Workplace from "../../components/layout/workplace";
import { Row, Col, Breadcrumb } from "antd";
import AddPersonForm from "../../components/form/form-add-person";
import { profile } from "console";
import useSWR from "swr";
import fetcher from "../../components/fetcher";
import LoadingSpin from "../../components/spin-loading";

const AddPerson = () => {
  const { data, error } = useSWR("/api/profile", fetcher);
  // BUG: data may not always be ready, so when read data.name, it will fail
  if (error) {
    console.log("fetch data error:", error);
  }
  if (!data) {
    return <LoadingSpin />;
  }

  const breadcrumb = (
    <Breadcrumb>
      <Breadcrumb.Item>人员信息管理</Breadcrumb.Item>
      <Breadcrumb.Item>添加</Breadcrumb.Item>
    </Breadcrumb>
  );
  return (
    <Workplace breadcrumb={breadcrumb} currentTab="add_person" profile={data}>
      <Row justify="center" align="top">
        <Col span={8}>
          <AddPersonForm />
        </Col>
      </Row>
    </Workplace>
  );
};
export default AddPerson;
